package cn.ac.jaas.ljx.java.serializable;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class SimpleSerial {

	public static void main(String[] args) throws Exception {
		File file = new File("person.txt");
		ObjectOutputStream oops = new ObjectOutputStream(new FileOutputStream(file));
		Person person = new Person("Tom", 18, Gender.MALE);
		oops.writeObject(person);
		oops.close();
		
		ObjectInputStream oips = new ObjectInputStream(new FileInputStream(file));
		Object newPerson = oips.readObject();
		oips.close();
		System.out.println(newPerson);
	}
}
